package sampleapp.server;

import java.util.ArrayList;
import java.util.List;

import sampleapp.shared.GetAllPeople;
import sampleapp.shared.GetAllPeopleResult;
import sampleapp.shared.PersonInfo;

import com.google.inject.Inject;
import com.gwtplatform.dispatch.server.ExecutionContext;
import com.gwtplatform.dispatch.server.actionhandler.ActionHandler;
import com.gwtplatform.dispatch.shared.ActionException;

public class GetAllPeopleActionHandler implements
		ActionHandler<GetAllPeople, GetAllPeopleResult> {

	@Inject
	public GetAllPeopleActionHandler() {
	}

	@Override
	public GetAllPeopleResult execute(GetAllPeople action, ExecutionContext context)
			throws ActionException {
		List<PersonInfo> lstPeople = new ArrayList<PersonInfo>();
		
		PersonInfo person1 = new PersonInfo();
		person1.setFirstName("Person1FirstName");
		person1.setLastName("Person1LastName");
		lstPeople.add(person1);
		
		PersonInfo person2 = new PersonInfo();
		person2.setFirstName("Person2FirstName");
		person2.setLastName("Person2LastName");
		lstPeople.add(person2);
		
		return new GetAllPeopleResult(lstPeople);
	}

	@Override
	public void undo(GetAllPeople action, GetAllPeopleResult result,
			ExecutionContext context) throws ActionException {
	}

	@Override
	public Class<GetAllPeople> getActionType() {
		return GetAllPeople.class;
	}
}
